package com.whxy02.tolearn.app.utils;

import com.whxy02.tolearn.app.beans.User;
import com.whxy02.tolearn.app.resultObject.ResultState;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;


/**
 *对返回的状态及数据打包的工具类
 */
@Component("packResult")
public class PackResult {

    public Map<String,Object> doPackToMap(ResultState resultState){
        Map<String,Object> result=new HashMap<>();
        result.put("msg",resultState.msg);
        result.put("code",resultState.code);
        return result;
    }

    public Map<String,Object> doPackToMap(ResultState resultState,Object data){
        Map<String,Object> result=new HashMap<>();
        result.put("msg",resultState.msg);
        result.put("code",resultState.code);
        result.put("data",data);
        return result;
    }

}
